#ifndef _SCANNER_H_
#define _SCANNER_H_

#ifndef YY_DECL

#define	YY_DECL						\
    netthumb::Parser::token_type				\
    netthumb::Scanner::lex(				\
	netthumb::Parser::semantic_type* yylval,		\
	netthumb::Parser::location_type* yylloc		\
    )
#endif

#ifndef __FLEX_LEXER_H
#define yyFlexLexer NetthumbFlexLexer
#include "FlexLexer.h"
#undef yyFlexLexer
#endif

#include "parser.tab.h"
#include <string>
#include <map>
#include <iostream>

  /* Importamos los tokens del parser */
  typedef netthumb::Parser::token token;
  typedef netthumb::Parser::token_type token_type;

namespace netthumb{
/** Scanner is a derived class to add some extra function to the scanner
 * class. Flex itself creates a class named yyFlexLexer, which is renamed using
 * macros to ExampleFlexLexer. However we change the context of the generated
 * yylex() function to be contained within the Scanner class. This is required
 * because the yylex() defined in ExampleFlexLexer has no parameters. */
class Scanner : public NetthumbFlexLexer
{
public:
    /** Create a new scanner object. The streams arg_yyin and arg_yyout default
     * to cin and cout, but that assignment is only made when initializing in
     * yylex(). */
    Scanner(std::istream* arg_yyin = 0,
	    std::ostream* arg_yyout = 0);

    /** Required for virtual functions */
    virtual ~Scanner();

    /** This is the main lexing function. It is generated by flex according to
     * the macro declaration YY_DECL above. The generated bison parser then
     * calls this virtual function to fetch new tokens. */
    virtual Parser::token_type lex(
	Parser::semantic_type* yylval,
	Parser::location_type* yylloc
	);

    /** Enable debug output (via arg_yyout) if compiled into the scanner. */
    void set_debug(bool b);

 private:
    std::map<std::string, token_type> reservadas;
    void initScanner();
    token_type checkKeyword(std::string);

};

}
#endif
